﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace VMExplorer.Win32
{
	// Remoting
  partial class Native
  {
    #region :: Enums ::
    #endregion
    #region :: Structs ::

    [StructLayout(LayoutKind.Sequential, Size = 0x18)]
    public struct RemoteThreadParameters
    {
      public IntPtr fnGetModuleHandle;
      public IntPtr fnGetProcAddress;
      public IntPtr lpModuleName;
      public IntPtr lpProcName;
      public UInt32 dwSuccess;
      public UInt32 dwResult;
    };

    #endregion
    #region :: API ::

    [DllImport("kernel32.dll")]
    public static extern bool WriteProcessMemory(SafeProcessHandle hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, uint nSize, out int lpNumberOfBytesWritten);

    [DllImport("kernel32.dll")]
    public static extern bool ReadProcessMemory(SafeProcessHandle hProcess, IntPtr lpBaseAddress, IntPtr lpBuffer, uint dwSize, out uint lpNumberOfBytesRead);

    [DllImport("kernel32.dll")]
    public static extern SafeProcessHandle CreateRemoteThread(SafeProcessHandle hProcess, IntPtr lpThreadAttributes, uint dwStackSize, IntPtr lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, IntPtr lpThreadId);

    [DllImport("kernel32.dll")]
    public static extern uint WaitForSingleObject(SafeProcessHandle hHandle, uint dwMilliseconds);

    [DllImport("kernel32.dll")]
    public static extern bool GetExitCodeThread(SafeProcessHandle hThread, out uint lpExitCode);
    
    #endregion
  }
}
